using System;
using System.IO;
using System.Net;
using System.Text;

namespace KnessetCore.Utils
{
	/// <summary>
	/// Various public static helper methods.
	/// </summary>
	public static class Helpers
	{
		/// <summary>
		/// Fetch text from an extrnal URL address.
		/// </summary>
		/// <param name="address">Address to fetch from.</param>
		/// <returns>The text found in the url.</returns>
		public static String GetTextFromURL(String address)
		{
			String text;
			
			// Create a request for the URL. 		
			WebRequest request = WebRequest.Create(address);
			// Get the response.
			WebResponse response = request.GetResponse();
			Stream stream = response.GetResponseStream();
			// Now slurp the object.
			StreamReader reader = new StreamReader(stream,Encoding.Default);
			text = reader.ReadToEnd();
			
			return text;
		}
	}
}